package com.bank.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
@ConfigurationProperties
@RequestMapping("/sampleController")
public class SampleController {
    protected Logger logger = LoggerFactory.getLogger(SampleController.class);
    @Value("${user.name:abc}")
    String userName;

    @Value("${user.age:25}")
    int age;

    @Value("${user.current:demo}")
    String current;

    @RequestMapping(value = "/simple",method = {RequestMethod.GET,RequestMethod.POST})
    public String simple() {
        logger.info("Hello Nacos Config!" + "userName: " + userName + "; age: " + age + "!" + " current:" + current);
        return "Hello Nacos Config!" + "Hello " + userName + " " + age + "!" + "current:" + current;
    }
}
